package com.example.service_provider.controller;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class HelloController {


    /*
    * openfeign
    *
    * */
    @Value("${server.port}")
    String servicePort;

//    @GetMapping("/provider/openfeign")
//    public String hiOpenfeign(){
//        return "provider port is:" + servicePort;
//    }

    @GetMapping("/provider/openfeign")
    public String hiOpenfeign() {
        // 创建一个较大的字符串，以确保数据足够大以触发压缩
        StringBuilder builder = new StringBuilder();
        for (int i = 0; i < 1000; i++) {
            builder.append("provider port is: ").append(servicePort).append("\n");
        }
        return builder.toString();
    }

    @GetMapping("/provider/hello")
    public String hello(){return "provider is here";}

    @GetMapping("/say/hi")
    public String hi(){return "hi provider";}

    /*
     *作业4：请求超时
     *
     * */
    @GetMapping("/provider/timeOut")
    public String requestTimeOut() throws InterruptedException {
        Thread.sleep(10000);
        return "provider port is: " + servicePort;
    }

}
